#include ("/_includes/_layout.html")
#@layout("设置交易密码", "wxmall,点步科技", "Wxmall社区","wxmall") 
#define content()
<div class="wrapper wrapper-content">
	<div class="content-tabs">
		<nav class="page-tabs J_menuTabs">
	       <div class="page-tabs-content" >
	       	   <a href="#(webctx)/user" class="J_menuTab active">修改交易密码</a>
	           <!-- <a href="#(webctx)/company" class="J_menuTab ">企业信息</a> -->
	       </div>
	   	</nav>
	</div>
	
	<div class="ibox-content" >
		<div class="contain-fluid" > 
			<form id="_myForm_" class="form-horizontal">
		        <div class="form-group">
		            <label class="col-md-3 control-label">手机号：</label>
		            <div class="col-md-3">
	                	<input type="text" id="phone" class="form-control" value="#shiroPrincipal() #(principal.phone) #end" readonly="readonly"/>
		            </div>
		        </div>
		        <div class="form-group">
		            <label class="col-md-3 control-label">短信验证码：</label>
		            <div class="col-md-3">
		            	<div class="input-group">
	                        <input type="text" name="code" class="form-control" value=""/>
	                        <span class="input-group-btn"><a id="sendCodeBtn" href="javascript:void(0)" class="btn btn-primary">发送验证码</a></span>
	                    </div>
		            </div>
		        </div>
		        <div class="form-group">
		            <label class="col-md-3 control-label">交易密码：</label>
		            <div class="col-md-3">
	                        <input type="password" name="password" class="form-control" value=""/>
		            </div>
		        </div>
		        <div class="form-group">
		            <label class="col-md-3 control-label">确认交易密码：</label>
		            <div class="col-md-3">
	                        <input type="password" name="confirmPwd" class="form-control" value=""/>
		            </div>
		        </div>
		        
		         <div class="form-group">
		            <div class="col-md-6" align="right">
		               <button type="submit" class="btn btn-success btn-sm">保存</button>
		               <a href="#(webctx)/user" class="btn btn-default btn-sm">取   消</a>
		            </div>
		        </div>
		       
			</form>
		</div>	
	</div>
</div>
#end
<script type="text/javascript">
$(document).ready(function(){
	$("#sendCodeBtn").click(function(){
		if($("#phone").val() == null || $("#phone").val() == ""){
			obz.warn("请输入手机号码");
			return;
		}
		$(".form-horizontal").mask("正在发送验证码...");
		obz.ajaxJson(obz.ctx+"/sendPwdCode", {phone:$("#phone").val()}, function(resp){
			$(".form-horizontal").unmask();
			if(resp.code == 200){
				obz.msg("短信验证码已发送，请留意手机短信");//alert(resp.msg);
			}
		});
	});
	//validate signup form on keyup and submit
	var icon = "<i class='fa fa-times-circle'></i> ";
	$("#_myForm_").validate({
		//debug:true,
		errorElement: "em",
	    success: function(em) {
	        em.text("").addClass("success");//验证通过的动态CSS
	    },
	    submitHandler: function() {
	    	obz.showMessage("确认保存吗?", function(){
	    		$("#_myForm_").mask("正在保存...");
		    	var params = $("#_myForm_").wxmall_serialize();
		    	obz.ajaxJson(obz.ctx+"/user/saveTradepwd", params, function(json) {
		    		$("#_myForm_").unmask();
					if(json.code!=200){
						obz.error(json.msg);
					}else{
						obz.msg('保存成功', function(){
							location.href="#(webctx)/user";
						});					
					}
				},"json");
	    	});
	    },
	    rules: {
	    	code: "required", password: "required", confirmPwd: "required"
	    },
	    messages: {
	    	code: icon + "请输入短信验证码", password: icon + "请输入交易密码", confirmPwd: icon + "请输入确认交易密码"
	    }
	});
});
</script>